#include "ScnsBeep.c.h"

#if defined(SCNS_BEEP_ENABLE)&&SCNS_BEEP_ENABLE==1

#if __SCNS_DEVICE_ID__==1

ScnsStatus scnsBspBeepInit(void)
{
    pwm_init(TIM_8,TIM_8_CH2_C07,15000,0);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspBeepPostInit(void)
{
    return SCNS_STATUS_OK;
}

void scnsBspBeepSet(ScnsBeepTone status)
{
    if(status==SCNS_BEEP_TONE_OFF)
        pwm_duty_updata(TIM_8,TIM_8_CH2_C07,0);
    else
        pwm_set_freq(TIM_8,TIM_8_CH2_C07,status,(PWM_DUTY_MAX*3/4));
}
#elif __SCNS_DEVICE_ID__==2
ScnsStatus scnsBspBeepInit(void)
{
    gpio_init(A15,GPO,0,GPO_PUSH_PULL);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspBeepPostInit(void)
{
    return SCNS_STATUS_OK;
}

void scnsBspBeepSet(ScnsBeepTone status)
{
    gpio_set(A15,status==SCNS_BEEP_TONE_OFF?0:1);
}

#else
#error
#endif

#endif